Imports System.Data.OleDb
Imports DTO

Public Class QuyDinhDAO
    Inherits DataProviderDAO

    Public Function LayBang() As DataTable
        Dim dt As DataTable
        Dim sql As String
        sql = "select * from QuyDinh"
        dt = Execute(sql)
        Return dt
    End Function
    Public Sub CapNhatQuyDinh(ByVal qd As QuiDinhDTO)
        ' Dim cn As OleDbConnection
        'B1 & B2: Tao chuoi ket noi, mo ket noi bang doi tuong ket noi
        'cn = Me.ConnectionData()
        Dim sql As String
        sql = "Update QuyDinh set TenQD='" + qd.TenQuyDinh + "',GiaTri=" + qd.GiaTri.ToString + " where MaQD=" + qd.MaQuyDinh.ToString
        'Dim cm As New OleDbCommand(sql, cn)
        ExecuteNonQuery(sql)
    End Sub

    ' lay si so toi da
    Public Function LaySiSoToiDa() As Integer
        Dim tuoi As Integer
        Dim cn As OleDbConnection
        cn = Me.ConnectionData()
        Dim strSql As String
        strSql = "select GiaTri from QuyDinh Where MaQD = 3"
        Dim cmd As New OleDbCommand(strSql, cn)
        tuoi = cmd.ExecuteScalar()
        Return tuoi
    End Function
End Class
